import router from '../router/index.js'

router.beforeEach((to, from, next) => {
    let userInfo = JSON.parse(localStorage.getItem('userInfo'));
    if(userInfo){
        next();
    }else {
        if(to.path ==='/'){
            localStorage.removeItem('userInfo');
            next();
        }else if(to.path === '/Register'){
            next();
        }else{
            next({
                path:'/'
            })
        }
    }
})



